package com.sh.data.engine.domain.integration.offline.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.sh.data.engine.domain.base.model.PageResult;
import com.sh.data.engine.domain.integration.offline.model.domain.*;
import com.sh.data.engine.domain.workspace.manager.model.domain.UserDomain;
import com.sh.data.engine.repository.dao.integration.offline.entity.OfflineSyncEntity;

import java.util.List;
import java.util.Map;

/**
 * @author: mengzheng.mhc
 * @date: 2024/6/18 11:07
 */
public interface OfflineSyncService extends IService<OfflineSyncEntity> {

    List<OfflineSyncDatabaseDomain> getOfflineSyncDatabases(Integer direction, String dsId);

    Map<Long, String> getOfflineSncMapByIds(List<Long> ids);

    void saveOrUpdateOfflineSyncTask(OfflineSyncDomain request);

    OfflineSyncDomain getOfflineSyncById(Long id);

    OfflineSyncDomain getOfflineSyncByXxlId(Long xxlId);

    List<OfflineSyncTableDomain> getOfflineSyncTables(Integer direction, Long dsId, String schema);

    OfflineTaskExistTableMappingDomain getExistTablesMappings(
        OfflineTaskExistTableMappingQueryDomain queryDomain);

    Boolean delOfflineSyncTask(Long id);

    void updateOfflineSyncTask(OfflineSyncDomain domain);

    void updateOfflineSyncEndStatus(Long taskId, Integer taskRunStatus);

    void stop(String jobId);

    String run(Long taskId, Integer runType);

    List<OfflineSyncPageDomain> getSyncList(Long projectId, Long dirId);

    PageResult<OfflineSyncPageDomain> getPageList(
        OfflineSyncTaskQueryDomain offlineSyncPageQueryDomain);

    List<OfflineSyncSimpleDomain> getOfflineSyncSimpleDomain(Long dsId, Long projectId);

    List<OfflineSyncSimpleDomain> getOfflineSyncListByProjectId(Long projectId);

    OfflineSyncStatisticsDomain statistics();

    void online(Long taskId);

    void offline(Long taskId);

    PageResult<OfflineSyncRunningRecordDomain> historyTask(OfflineSyncTaskQueryDomain queryDomain);

    Boolean deleteDir(Long id);

    /**
     * @description : 根据项目和表名，找到离线同步任务
     * @author : tinglan.ys
     * @date : 2022/5/7
     */
    List<OfflineSyncDomain> getOfflineTask(Long projectId, String tableName);

    OfflineSyncLogDomain getOfflineSyncLog(Long logId, Integer offset);

    void updateRunningRecord(Long logId);

    String saveXxlJob(Long id, boolean reset);

    List<OfflineSyncDomain> getListByPage(Long projectId, Integer pageSize, Integer pageNum);

    List<UserDomain> getUserIds(Long projectId);


    List<OfflineSyncEntity> getOfflineSyncByProjectId(Long projectId);

    List<String> getNodeTableById(Long jobId);
}
